package fu.k4c.vTeam.Search;

import java.lang.reflect.Type;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;

import org.apache.http.HttpEntity;
import org.apache.http.HttpResponse;
import org.apache.http.client.HttpClient;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.conn.scheme.PlainSocketFactory;
import org.apache.http.conn.scheme.Scheme;
import org.apache.http.conn.scheme.SchemeRegistry;
import org.apache.http.entity.StringEntity;
import org.apache.http.impl.client.DefaultHttpClient;
import org.apache.http.impl.conn.tsccm.ThreadSafeClientConnManager;
import org.apache.http.params.BasicHttpParams;
import org.apache.http.params.HttpParams;
import org.apache.http.util.EntityUtils;

import com.google.gson.Gson;
import com.google.gson.reflect.TypeToken;
import com.nostra13.universalimageloader.core.DisplayImageOptions;
import com.nostra13.universalimageloader.core.ImageLoaderConfiguration;
import com.nostra13.universalimageloader.core.assist.SimpleImageLoadingListener;
import com.nostra13.universalimageloader.core.display.RoundedBitmapDisplayer;

import android.app.Activity;
import android.app.ProgressDialog;
import android.content.Intent;
import android.graphics.Bitmap;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.view.View.OnClickListener;
import android.view.animation.Animation;
import android.view.animation.AnimationUtils;
import android.widget.AdapterView;
import android.widget.ArrayAdapter;
import android.widget.BaseAdapter;
import android.widget.Button;
import android.widget.EditText;
import android.widget.GridView;
import android.widget.ImageView;
import android.widget.Spinner;
import android.widget.TextView;
import android.widget.Toast;
import android.widget.AdapterView.OnItemClickListener;
import fu.k4c.vTeam.R;
import fu.k4c.vTeam.Main.BaseActivity;
import fu.k4c.vTeam.Main.ViewEventActivity;
import fu.k4c.vTeam.Object.EventDetails;
import fu.k4c.vTeam.Object.PlaceDetails;
import fu.k4c.vTeam.Object.SearchByContent;
import fu.k4c.vTeam.ViewDetails.EventTabLayoutActivity;
import fu.k4c.vTeam.ViewDetails.InfoEventActivity;
import fu.k4c.vTeam.ViewDetails.PlaceTabLayoutActivity;

public class SearchActivity extends BaseActivity {
	String categories;
	String citi;
	String op;
	private DisplayImageOptions options;
	GridView gv_search;
	GridView gv_search2;
	Spinner Cityspinner;
	Spinner CateSpinner;
	Spinner OptionSpinner;
	String status;
	EditText et_search;
	String email = "";
	List<SearchByContent> yourClassList;
	int CURRENT_TAG = 0;
	static final int TAG_GUEST = 0;
	static final int TAG_USER = 1;
	EditText searchcontent;
	ProgressDialog proDialog;
	String cities[] = { "Hà Nội", "TP Hồ Chí Minh", "Khác" };
	String category[] = { "Ẩm thực", "Bệnh viện", "Cà phê", "Mua sắm",
			"Trạm xăng", "Giải trí", "ATM", "Sự kiện" };
	String option[] = { "Chỉ tìm trong tiêu đề", "Chỉ tìm trong nội dung",
			"Tìm trong cả tiêu đề và nội dung" };

	protected void onCreate(Bundle savedInstanceState) {
		// TODO Auto-generated method stub
		super.onCreate(savedInstanceState);
		setContentView(R.layout.search);
		options = new DisplayImageOptions.Builder()
				.showStubImage(R.drawable.stub_image)
				.showImageForEmptyUri(R.drawable.image_for_empty_url)
				.cacheInMemory().cacheOnDisc()
				.displayer(new RoundedBitmapDisplayer(20)).build();

		Bundle data = getIntent().getExtras();

		if (data != null) {
			status = data.getString("status");
			email = data.getString("email");

		}
		if (status.equals("True")) {
			CURRENT_TAG = TAG_USER;
		} else {
			CURRENT_TAG = TAG_GUEST;

		}
		gv_search = (GridView) findViewById(R.id.gv_search);
		et_search = (EditText) findViewById(R.id.et_search_content);
		Button btn_search = (Button) findViewById(R.id.btn_search_submit);
		btn_search.setOnClickListener(new OnClickListener() {

			public void onClick(View v) {
				// TODO Auto-generated method stub
				proDialog = ProgressDialog.show(SearchActivity.this, "",
						"Đang tải dữ liệu...");
				new Thread() {
					public void run() {

						try {
							sleep(1000);
						} catch (Exception e) {
							System.out.print(e.toString());
						}
						// dismiss the progressdialog
						proDialog.dismiss();
					}
				}.start();
				try {

					SchemeRegistry registry = new SchemeRegistry();
					registry.register(new Scheme("http", PlainSocketFactory
							.getSocketFactory(), 80));
					HttpParams httpParams = new BasicHttpParams();
					ThreadSafeClientConnManager connMgr = new ThreadSafeClientConnManager(
							httpParams, registry);
					HttpClient client = new DefaultHttpClient(connMgr,
							httpParams);
					HttpPost post = new HttpPost(
							getString(R.string.connectionString)
									+ "vLocationService/SearchByContent");
					post.setHeader("Accept", "application/json");
					post.setHeader("Content-type", "application/json");
					HashMap<String, Object> postParameters = new HashMap<String, Object>();
					postParameters.put("categorieName", categories);
					postParameters.put("cityID", citi);
					postParameters.put("contentSearch", et_search.getText()
							.toString());
					postParameters.put("typeOfSearch", op);
					if(CURRENT_TAG==TAG_GUEST)
					{
						postParameters.put("email", "Guest");
					}
					else
					{
						postParameters.put("email", email);
					}
					Gson gson = new Gson();
					String jsonParameters = gson.toJson(postParameters);
					post.setEntity(new StringEntity(jsonParameters));
					HttpResponse response = client.execute(post);

					HttpEntity entity = response.getEntity();
					String jsonresult = EntityUtils.toString(entity);

					try {
						Type listType = new TypeToken<ArrayList<SearchByContent>>() {
						}.getType();
						yourClassList = new Gson().fromJson(jsonresult,
								listType);

						if (yourClassList.size() == 0) {
							Toast.makeText(getApplicationContext(),
									"Không tìm được kết quả nào theo yêu cầu",
									Toast.LENGTH_LONG).show();
						} else {
							Toast.makeText(getApplicationContext(),
									"Có " + yourClassList.size() + " kết quả",
									Toast.LENGTH_LONG).show();
						}
						if (categories.equals("sukien")) {
							// Toast.makeText(getApplicationContext(),
							// yourClassList.get(0).getAvatar(),
							// Toast.LENGTH_LONG).show();
							ListSearchEvent adapter = new ListSearchEvent(
									SearchActivity.this, yourClassList);
							gv_search.setAdapter(adapter);
							gv_search
									.setOnItemClickListener(new OnItemClickListener() {

										public void onItemClick(
												AdapterView<?> arg0, View v,
												int position, long id) {
											// TODO Auto-generated method stub
											proDialog = ProgressDialog.show(
													SearchActivity.this, "",
													"Đang tải dữ liệu...");
											new Thread() {
												public void run() {

													try {
														sleep(2000);

													} catch (Exception e) {
														System.out.print(e
																.toString());
													}
													// dismiss the
													// progressdialog
													proDialog.dismiss();
												}
											}.start();
											SchemeRegistry registry = new SchemeRegistry();
											registry.register(new Scheme(
													"http",
													PlainSocketFactory
															.getSocketFactory(),
													80));
											HttpParams httpParams = new BasicHttpParams();
											ThreadSafeClientConnManager connMgr = new ThreadSafeClientConnManager(
													httpParams, registry);
											HttpClient client = new DefaultHttpClient(
													connMgr, httpParams);
											HttpPost post = new HttpPost(
													getString(R.string.connectionString)
															+ "vLocationService/getdetailevent");
											post.setHeader("Accept",
													"application/json");
											post.setHeader("Content-type",
													"application/json");
											HashMap<String, Object> postParameters = new HashMap<String, Object>();
											// Toast.makeText(getApplicationContext(),yourClassList.get(position).getAddress(),
											// Toast.LENGTH_LONG).show();
											postParameters.put(
													"IDofItemRevision",
													yourClassList.get(position)
															.getIdPlace());
											postParameters.put("username",
													email);
											Gson gson = new Gson();
											try {
												String jsonParameters = gson
														.toJson(postParameters);
												// Toast.makeText(getApplicationContext(),""+jsonParameters,
												// Toast.LENGTH_LONG).show();
												post.setEntity(new StringEntity(
														jsonParameters));
												HttpResponse response = client
														.execute(post);
												HttpEntity entity = response
														.getEntity();
												String jsonresult = EntityUtils
														.toString(entity);
												// Toast.makeText(getApplicationContext(),""+jsonresult,
												// Toast.LENGTH_LONG).show();
												EventDetails mDetails = gson
														.fromJson(
																jsonresult,
																EventDetails.class);
												Intent i = new Intent(
														SearchActivity.this,
														EventTabLayoutActivity.class);

												i.putExtra(
														"address",
														""
																+ yourClassList
																		.get(position)
																		.getAddress());
												i.putExtra("placename",
														mDetails.getReName());
												i.putExtra("placetel",
														mDetails.getRePhone());
												i.putExtra("likenumber",
														mDetails.getReslVote());
												i.putExtra("visitnumber",
														mDetails.getReslVisit());
												i.putExtra("createby",
														mDetails.getReCreatBy());
												i.putExtra("des", mDetails
														.getReDescription());
												i.putExtra("lat",
														mDetails.getRelat());
												i.putExtra("long",
														mDetails.getRelong());
												i.putExtra("visit",
														mDetails.isReDaDen());
												i.putExtra("like",
														mDetails.isReLike());
												i.putExtra("begin",
														mDetails.getStartDate());
												i.putExtra("end",
														mDetails.getEndDate());
												i.putExtra(
														"IDofItemRevision",
														yourClassList.get(
																position)
																.getIdPlace());
												i.putExtra(
														"views",
														""
																+ mDetails
																		.getSolgnguoiview());
												i.putExtra(
														"avatar",
														""
																+ mDetails
																		.getImageUrl());
												i.putExtra("createbyemail", ""
														+ mDetails.getEmail());
												if (CURRENT_TAG == TAG_USER) {
													i.putExtra("username",
															email);
												} else {
													i.putExtra("username",
															"Guest");
												}
												startActivity(i);
											} catch (Exception e) {
												// TODO: handle exception
												Toast.makeText(
														getApplicationContext(),
														e.toString(),
														Toast.LENGTH_LONG)
														.show();
											}
										}
									});
						} else {
							ListSearchContent adapter = new ListSearchContent(
									SearchActivity.this, yourClassList);
							gv_search.setAdapter(adapter);
							gv_search
									.setOnItemClickListener(new OnItemClickListener() {
										public void onItemClick(
												AdapterView<?> arg0, View v,
												int position, long id) {

											SchemeRegistry registry = new SchemeRegistry();
											registry.register(new Scheme(
													"http",
													PlainSocketFactory
															.getSocketFactory(),
													80));
											HttpParams httpParams = new BasicHttpParams();
											ThreadSafeClientConnManager connMgr = new ThreadSafeClientConnManager(
													httpParams, registry);
											HttpClient client = new DefaultHttpClient(
													connMgr, httpParams);
											HttpPost post = new HttpPost(
													getString(R.string.connectionString)
															+ "vLocationService/GetDetailLocation");
											post.setHeader("Accept",
													"application/json");
											post.setHeader("Content-type",
													"application/json");
											HashMap<String, Object> postParameters = new HashMap<String, Object>();
											postParameters.put(
													"IDofItemRevision",
													yourClassList.get(position)
															.getIdPlace());
											postParameters.put("username",
													email);
											Gson gson = new Gson();
											try {
												String jsonParameters = gson
														.toJson(postParameters);
												post.setEntity(new StringEntity(
														jsonParameters));
												HttpResponse response = client
														.execute(post);
												HttpEntity entity = response
														.getEntity();
												String jsonresult = EntityUtils
														.toString(entity);
												PlaceDetails mDetails = gson
														.fromJson(
																jsonresult,
																PlaceDetails.class);
												Intent i = new Intent(
														SearchActivity.this,
														PlaceTabLayoutActivity.class);
												// Toast.makeText(getApplicationContext(),""+mDetails.isReLike(),
												// Toast.LENGTH_LONG).show();
												i.putExtra(
														"address",
														""
																+ yourClassList
																		.get(position)
																		.getAddress());
												i.putExtra("placename",
														mDetails.getReName());
												i.putExtra("placetel",
														mDetails.getRePhone());
												i.putExtra("likenumber",
														mDetails.getReslVote());
												i.putExtra("visitnumber",
														mDetails.getReslVisit());
												i.putExtra("createby",
														mDetails.getReCreatBy());
												i.putExtra("des", mDetails
														.getReDescription());
												i.putExtra("lat",
														mDetails.getRelat());
												i.putExtra("long",
														mDetails.getRelong());
												i.putExtra("visit",
														mDetails.isReDaDen());
												i.putExtra("like",
														mDetails.isReLike());
												i.putExtra(
														"IDofItemRevision",
														yourClassList.get(
																position)
																.getIdPlace());
												i.putExtra(
														"views",
														""
																+ mDetails
																		.getSolgnguoiview());
												i.putExtra("createbyemail", ""
														+ mDetails.getEmail());
												if (CURRENT_TAG == TAG_USER) {
													i.putExtra("username",
															email);
												} else {
													i.putExtra("username",
															"Guest");
												}
												startActivity(i);
												// i.putExtra("linkanh",image);
												// Toast.makeText(getApplicationContext(),mDetails.getRelat()+", "+mDetails.getRelong(),
												// Toast.LENGTH_LONG).show();
											} catch (Exception e) {
												// TODO: handle exception
												Toast.makeText(
														getApplicationContext(),
														e.toString(),
														Toast.LENGTH_LONG)
														.show();
											}
										}
									});
						}
						// Toast.makeText(getApplicationContext(),""+jsonresult,
						// Toast.LENGTH_LONG).show();
					} catch (Exception e) {
						Toast.makeText(getApplicationContext(),
								"Loi : " + e.toString(), Toast.LENGTH_LONG)
								.show();
						// TODO: handle exception
					}
				} catch (Exception e) {
					// TODO: handle exception
					Toast.makeText(
							getApplicationContext(),
							"Bạn vui lòng kiểm tra lại kết nối Internet "
									+ e.toString(), Toast.LENGTH_LONG).show();
				}
			}
		});
		Button btn_back = (Button) findViewById(R.id.btn_search_back);
		btn_back.setOnClickListener(new OnClickListener() {

			public void onClick(View v) {
				// TODO Auto-generated method stub
				finish();
			}
		});

		CateSpinner = (Spinner) findViewById(R.id.sp_search_category);
		Cityspinner = (Spinner) findViewById(R.id.sp_search_city);
		OptionSpinner = (Spinner) findViewById(R.id.sp_search_option);
		ArrayAdapter<String> spinnerArrayAdapter1 = new ArrayAdapter<String>(
				this, android.R.layout.simple_spinner_item, category);
		spinnerArrayAdapter1
				.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); // The
																							// drop
																							// down
																							// vieww
		CateSpinner.setAdapter(spinnerArrayAdapter1);
		ArrayAdapter<String> spinnerArrayAdapter2 = new ArrayAdapter<String>(
				this, android.R.layout.simple_spinner_item, cities);
		spinnerArrayAdapter2
				.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); // The
																							// drop
																							// down
																							// vieww
		Cityspinner.setAdapter(spinnerArrayAdapter2);
		ArrayAdapter<String> spinnerArrayAdapter3 = new ArrayAdapter<String>(
				this, android.R.layout.simple_spinner_item, option);
		spinnerArrayAdapter3
				.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); // The
																							// drop
																							// down
																							// vieww
		OptionSpinner.setAdapter(spinnerArrayAdapter3);
		CateSpinner
				.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
					public void onItemSelected(AdapterView<?> parent,
							View view, int pos, long id) {
						Object item = parent.getItemAtPosition(pos);
						String catechoise = item.toString();
						if (catechoise.equals("Ẩm thực")) {
							categories = "amthuc";
						} else if (catechoise.equals("Bệnh viện")) {
							categories = "benhvien";
						} else if (catechoise.equals("Cà phê")) {
							categories = "cafe";
						} else if (catechoise.equals("Mua sắm")) {
							categories = "shopping";
						} else if (catechoise.equals("Trạm xăng")) {
							categories = "tramxang";
						} else if (catechoise.equals("Giải trí")) {
							categories = "giaitri";
						} else if (catechoise.equals("ATM")) {
							categories = "atm";
						} else if (catechoise.equals("Sự kiện")) {
							categories = "sukien";
						}

					}

					public void onNothingSelected(AdapterView<?> parent) {
					}
				});
		Cityspinner
				.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
					public void onItemSelected(AdapterView<?> parent,
							View view, int pos, long id) {
						Object item = parent.getItemAtPosition(pos);
						String catechoise = item.toString();
						if (catechoise.equals("TP Hồ Chí Minh")) {
							citi = "2";
						} else if (catechoise.equals("Hà Nội")) {
							citi = "1";
						} else if (catechoise.equals("Khác")) {
							citi = "3";
						}

					}

					public void onNothingSelected(AdapterView<?> parent) {
					}
				});
		OptionSpinner
				.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
					public void onItemSelected(AdapterView<?> parent,
							View view, int pos, long id) {
						Object item = parent.getItemAtPosition(pos);
						String catechoise = item.toString();
						if (catechoise.equals("Chỉ tìm trong tiêu đề")) {
							op = "1";
						} else if (catechoise.equals("Chỉ tìm trong nội dung")) {
							op = "2";
						} else {
							op = "3";
						}
					}

					public void onNothingSelected(AdapterView<?> parent) {
					}
				});

	}

	public class ListSearchContent extends BaseAdapter {
		Activity ListSearchContent;
		List<SearchByContent> data;
		LayoutInflater inflater = null;

		private class ViewHolder {
			public TextView tv_name;
			public TextView tv_phone;
			public TextView tv_address;
			public TextView tv_view;
			public ImageView imv_avatar;
		}

		public ListSearchContent(Activity mListCategoriesView,
				List<SearchByContent> mdata) {
			ListSearchContent = mListCategoriesView;
			data = mdata;

		}

		public int getCount() {
			// TODO Auto-generated method stub
			return data.size();
		}

		public Object getItem(int position) {
			// TODO Auto-generated method stub
			return data.get(position);
		}

		public long getItemId(int arg0) {
			// TODO Auto-generated method stub
			return arg0;
		}

		public View getView(int position, View convertView, ViewGroup arg2) {
			// TODO Auto-generated method stub
			View view = convertView;
			final ViewHolder holder;
			if (convertView == null) {
				view = getLayoutInflater().inflate(
						R.layout.row_view_by_categories, null);
				holder = new ViewHolder();
				holder.imv_avatar = (ImageView) view
						.findViewById(R.id.imv_row_view);
				holder.tv_name = (TextView) view
						.findViewById(R.id.tv_row_view_name);
				holder.tv_phone = (TextView) view
						.findViewById(R.id.tv_row_view_phone);
				holder.tv_address = (TextView) view
						.findViewById(R.id.tv_row_view_address);
				holder.tv_view = (TextView) view
						.findViewById(R.id.tv_row_view_views);
				view.setTag(holder);
			} else
				holder = (ViewHolder) view.getTag();
			String imageurl;
			if (data.get(position).getAvatar() != null) {
				if (data.get(position).getAvatar().toLowerCase()
						.indexOf("http://") >= 0) {
					imageurl = data.get(position).getAvatar();

				} else {
					imageurl = getString(R.string.connectionString)
							+ data.get(position).getAvatar();
				}
			} else {
				imageurl = data.get(position).getAvatar();
			}
			imageLoader.init(ImageLoaderConfiguration
					.createDefault(getBaseContext()));
			// imageLoader.displayImage(data.get(position).getAvatar(),
			// holder.imv_avatar, options);
			imageLoader.displayImage(imageurl, holder.imv_avatar, options,
					new SimpleImageLoadingListener() {
						@Override
						public void onLoadingComplete(Bitmap loadedImage) {
							Animation anim = AnimationUtils.loadAnimation(
									SearchActivity.this, R.anim.fade_in);
							holder.imv_avatar.setAnimation(anim);
							anim.start();
						}
					});
			holder.tv_name.setText(data.get(position).getName());
			if (data.get(position).getPhone() == null) {
				holder.tv_phone.setText("Số điện thoại : N\\A");
			} else
				holder.tv_phone.setText("Số điện thoại : "
						+ data.get(position).getPhone());
			holder.tv_address.setText("Địa chỉ : "
					+ data.get(position).getAddress());
			holder.tv_view.setText("Lượt xem : "
					+ data.get(position).getViews());
			return view;
		}

	}

	public class ListSearchEvent extends BaseAdapter {
		Activity listEvent;
		List<SearchByContent> data;
		LayoutInflater inflater = null;

		private class ViewHolder {
			public TextView tv_name;
			public TextView tv_phone;
			public TextView tv_address;
			public TextView tv_view;
			public ImageView img_avatar;
			public TextView tv_start;
			public TextView tv_end;
		}

		public ListSearchEvent(Activity mlistEvent, List<SearchByContent> mdata) {
			listEvent = mlistEvent;
			data = mdata;
		}

		public int getCount() {
			// TODO Auto-generated method stub
			return data.size();
		}

		public Object getItem(int arg0) {
			// TODO Auto-generated method stub
			return data.get(arg0);
		}

		public long getItemId(int arg0) {
			// TODO Auto-generated method stub
			return 0;
		}

		public View getView(int position, View convertView, ViewGroup arg2) {
			// TODO Auto-generated method stub
			View view = convertView;
			final ViewHolder holder;
			if (convertView == null) {
				view = getLayoutInflater().inflate(R.layout.row_event, null);
				holder = new ViewHolder();

				holder.tv_name = (TextView) view
						.findViewById(R.id.tv_row_event_name);
				holder.tv_phone = (TextView) view
						.findViewById(R.id.tv_row_event_phone);
				holder.tv_address = (TextView) view
						.findViewById(R.id.tv_row_event_address);
				holder.tv_start = (TextView) view
						.findViewById(R.id.tv_row_event_start);
				holder.tv_end = (TextView) view
						.findViewById(R.id.tv_row_event_end);
				holder.tv_view = (TextView) view
						.findViewById(R.id.tv_row_event_views);
				holder.img_avatar = (ImageView) view
						.findViewById(R.id.imv_row_event);
				view.setTag(holder);
			} else
				holder = (ViewHolder) view.getTag();

			holder.tv_name.setText(data.get(position).getName());
			if (data.get(position).getPhone() != null) {
				holder.tv_phone.setText("Số điện thoại : "
						+ data.get(position).getPhone());
			} else {
				holder.tv_phone.setText("Số điện thoại : N\\A");
			}
			holder.tv_address.setText("Địa chỉ : "
					+ data.get(position).getAddress());
			holder.tv_start.setText("Bắt đầu : "
					+ data.get(position).getStartDate());
			holder.tv_end.setText("Kết thúc : "
					+ data.get(position).getEndDate());
			String imageurl;
			if (data.get(position).getAvatar() != null) {
				if (data.get(position).getAvatar().toLowerCase()
						.indexOf("http://") >= 0) {
					imageurl = data.get(position).getAvatar();

				} else {
					imageurl = getString(R.string.connectionString)
							+ data.get(position).getAvatar();
				}
			} else {
				imageurl = data.get(position).getAvatar();
			}
			imageLoader.init(ImageLoaderConfiguration
					.createDefault(getBaseContext()));
			imageLoader.displayImage(imageurl, holder.img_avatar, options,
					new SimpleImageLoadingListener() {
						@Override
						public void onLoadingComplete(Bitmap loadedImage) {
							Animation anim = AnimationUtils.loadAnimation(
									SearchActivity.this, R.anim.fade_in);
							holder.img_avatar.setAnimation(anim);
							anim.start();
						}
					});
			if (data.get(position).getViews() != null) {
				holder.tv_view.setText("Lượt xem : "
						+ data.get(position).getViews());
			} else {
				holder.tv_view.setText("Lượt xem : 0");
			}
			return view;
		}

	}
}
